home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
IPFlakeWay
/
Squelch Module
/
source
/
NatEmbedded.h
< prev
next >
Wrap
Text File
|
2000-06-23
|
2KB
|
55 lines
// =================================================================================
// NatEmbedded.h ©1998 Sustainable Softworks. All rights reserved.
// =================================================================================
// Network Address Translation for Embedded Data
// This module translates the data portion of IP datagrams
// (technically a layering violation)
//
// Since we must operate in the STREAMS context, this module is written
// in traditional C (not C++).
#ifndef _H_NatEmbedded
#define _H_NatEmbedded
#pragma once
// ---------------------------------------------------------------------------
// • FindByte
// ---------------------------------------------------------------------------
// Find Byte in data block (match upper or lower case)
// Input: data block, first byte offset, last byte offset, byte to look for
// Output: offset of byte or Zero if not found
UInt16
FindByte(UInt8* data, UInt16 inFirst, UInt16 inLast, UInt8 inByte);
// support functions
Boolean IsDigit(UInt8 inDigit);
UInt8 GetOctet(UInt8* inStr, UInt16 inSize, UInt8* ioPos, OSStatus* outErr);
void PutOctet(UInt8 inOctet, UInt8* ioPos, char* outStr);
// ---------------------------------------------------------------------------
// • itoc
// ---------------------------------------------------------------------------
// Convert integer to character string and return length of string.
// May be called at interrupt time (unlike NumToString).
// Leave unterminated so we can append digits in place.
//
// A 32-bit integer can produce 10 decimal digits plus a sign and null byte
// so outStr should be at least 12 characters long.
UInt8
itoc(SInt32 inNum, char* outStr);
// ---------------------------------------------------------------------------
// • ctoi
// ---------------------------------------------------------------------------
// Convert sequence of decimal digits to an integer
// Stop at first non-digit character and return number of characters converted.
// A 32-bit int can hold a 10 digit decimal, so convert up to 10 characters max.
UInt8
ctoi(char* inStr, SInt32* outNum);
#define kFtpControlPort 21
#define kFtpDataPort 20
#endif